﻿--
-- Dropping stored procedure pr_HoaDonBanHang_SelectAll : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HoaDonBanHang_SelectAll]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HoaDonBanHang_SelectAll]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HoaDonBanHang_SelectAll
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:03 PM
-- Description:	This stored procedure is intended for selecting all rows from HoaDonBanHang table
-- ==========================================================================================
Create Procedure pr_HoaDonBanHang_SelectAll
As
Begin
	Select 
		[MaHD],
		[MaKH],
		[MaSoThue],
		[NgayHD],
		[TongTienHang],
		[ThueSuatGTGT],
		[TienThueGTGT],
		[PhiVanChuyen],
		[TongTienThanhToan],
		[TongTienBangChu],
		[MaNV]
	From HoaDonBanHang
End

GO


--
-- Dropping stored procedure pr_HoaDonBanHang_SelectRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HoaDonBanHang_SelectRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HoaDonBanHang_SelectRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HoaDonBanHang_SelectRow
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:03 PM
-- Description:	This stored procedure is intended for selecting a specific row from HoaDonBanHang table
-- ==========================================================================================
Create Procedure pr_HoaDonBanHang_SelectRow
	@MaHD varchar(10)
As
Begin
	Select 
		[MaHD],
		[MaKH],
		[MaSoThue],
		[NgayHD],
		[TongTienHang],
		[ThueSuatGTGT],
		[TienThueGTGT],
		[PhiVanChuyen],
		[TongTienThanhToan],
		[TongTienBangChu],
		[MaNV]
	From HoaDonBanHang
	Where
		[MaHD] = @MaHD
End

GO


--
-- Dropping stored procedure pr_HoaDonBanHang_Insert : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HoaDonBanHang_Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HoaDonBanHang_Insert]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HoaDonBanHang_Insert
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:03 PM
-- Description:	This stored procedure is intended for inserting values to HoaDonBanHang table
-- ==========================================================================================
Create Procedure pr_HoaDonBanHang_Insert
	@MaHD varchar(10),
	@MaKH varchar(10),
	@MaSoThue varchar(50),
	@NgayHD datetime,
	@TongTienHang decimal,
	@ThueSuatGTGT int,
	@TienThueGTGT decimal,
	@PhiVanChuyen decimal,
	@TongTienThanhToan decimal,
	@TongTienBangChu nvarchar(200),
	@MaNV varchar(10)
As
Begin
	Insert Into HoaDonBanHang
		([MaHD],[MaKH],[MaSoThue],[NgayHD],[TongTienHang],[ThueSuatGTGT],[TienThueGTGT],[PhiVanChuyen],[TongTienThanhToan],[TongTienBangChu],[MaNV])
	Values
		(@MaHD,@MaKH,@MaSoThue,@NgayHD,@TongTienHang,@ThueSuatGTGT,@TienThueGTGT,@PhiVanChuyen,@TongTienThanhToan,@TongTienBangChu,@MaNV)

End

GO


--
-- Dropping stored procedure pr_HoaDonBanHang_Update : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HoaDonBanHang_Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HoaDonBanHang_Update]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HoaDonBanHang_Update
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:03 PM
-- Description:	This stored procedure is intended for updating HoaDonBanHang table
-- ==========================================================================================
Create Procedure pr_HoaDonBanHang_Update
	@MaHD varchar(10),
	@MaKH varchar(10),
	@MaSoThue varchar(50),
	@NgayHD datetime,
	@TongTienHang decimal,
	@ThueSuatGTGT int,
	@TienThueGTGT decimal,
	@PhiVanChuyen decimal,
	@TongTienThanhToan decimal,
	@TongTienBangChu nvarchar(200),
	@MaNV varchar(10)
As
Begin
	Update HoaDonBanHang
	Set
		[MaKH] = @MaKH,
		[MaSoThue] = @MaSoThue,
		[NgayHD] = @NgayHD,
		[TongTienHang] = @TongTienHang,
		[ThueSuatGTGT] = @ThueSuatGTGT,
		[TienThueGTGT] = @TienThueGTGT,
		[PhiVanChuyen] = @PhiVanChuyen,
		[TongTienThanhToan] = @TongTienThanhToan,
		[TongTienBangChu] = @TongTienBangChu,
		[MaNV] = @MaNV
	Where		
		[MaHD] = @MaHD

End

GO


--
-- Dropping stored procedure pr_HoaDonBanHang_DeleteRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_HoaDonBanHang_DeleteRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_HoaDonBanHang_DeleteRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_HoaDonBanHang_DeleteRow
-- Author:	MinhNN
-- Create date:	5/14/2012 10:00:03 PM
-- Description:	This stored procedure is intended for deleting a specific row from HoaDonBanHang table
-- ==========================================================================================
Create Procedure pr_HoaDonBanHang_DeleteRow
	@MaHD varchar(10)
As
Begin
	Delete HoaDonBanHang
	Where
		[MaHD] = @MaHD

End

GO
